﻿using System;
using System.Data;
using System.Reflection;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;
namespace AnyOffice.general.system.workflow.flow_type
{
    public partial class type_sort : ModulePage
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);     

        protected override void OnInit(EventArgs e)
        {
            this.rptSort.ItemDataBound += new RepeaterItemEventHandler(this.rptSort_ItemDataBound);
            base.OnInit(e);
        }

        private void rptSort_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                HtmlInputHidden hidden = (HtmlInputHidden) e.Item.FindControl("iptSortId");
                if (hidden != null)
                {
                    Repeater repeater = (Repeater) e.Item.FindControl("rptFlowType");
                    if (repeater != null)
                    {
                        try
                        {
                            DataTable table = new FlowTypeDao().SelectByFlowSort(base.Conn, Convert.ToInt32(hidden.Value));
                            repeater.DataSource = table;
                            repeater.DataBind();
                        }
                        catch (Exception exception)
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.Error("", exception);
                            }
                        }
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable table = new FlowSortDao().SelectAll(base.Conn);
            if (table.Rows.Count > 0)
            {
                this.rptSort.DataSource = table;
                this.rptSort.DataBind();
            }
            else
            {
                this.litMessage.Text = base.ShowMessage("暂无流程");
            }
        }
      
    }
}

